package com.hntx.joymusic.util;

import android.content.Context;
import android.content.pm.PackageManager;

public class VersionInfoUtils {

    public static int getVersionCode(Context context) {
        try {
            return context.getPackageManager().getPackageInfo
                    (context.getPackageName(), 0).versionCode;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return 0;
    }

    public static String getAPKVersion(Context context) {
        PackageManager p;
        try {
            p = context.getPackageManager();
            String str1 = context.getPackageName();
            String versionName = p.getPackageInfo(str1, 0).versionName;
            return versionName;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return null;
    }
}
